/*
 * @Description: 
 * @Autor: fage
 * @Date: 2022-06-06 14:25:14
 * @LastEditors: fage
 * @LastEditTime: 2022-07-06 19:52:07
 */
var vm = new Vue({
  el: "#app",
  data: {
    loading: false,
    ruleForm: {
      username: "",
      password: "",
    },
    rules: {
      username: [{ required: true, message: "请输入用户名", trigger: "blur" }],
      password: [{ required: true, message: "请输入密码", trigger: "blur" }],
    },
  },
  methods: {
    submitForm(formName) {
      const that = this;
      this.$refs[formName].validate((valid) => {
        if (valid) {
          ajax.post("/api/login", that.ruleForm).then((t) => {
            console.log('data:',t);
            if (t.msg == "ok") {
              that.$message({
                message: "登录成功！",
                type: "success",
              });
              window.location.href='manage';
            } else {
              that.$message({
                message: "登录失败:"+t.msg,
                type: "error",
              });
            }
          }, console.log);
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
});
